// #ifndef VUE3
import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
import * as Pinia from 'pinia';
import App from './App.vue'
import {
	useGlobalStore
} from '@/stores'

export function createApp() {
	const app = createSSRApp(App)
	app.use(Pinia.createPinia());

	const globalStore = useGlobalStore()
	const userInfo = uni.getStorageSync('userInfo')
	userInfo && globalStore.setUserInfo(JSON.parse(userInfo))

	uni.getSystemInfo({
		success: (res) => {
			globalStore.setSafeArea({
				screenHeight: res.screenHeight,
				topBorder: res.safeArea.top,
				bottomBorder: res.safeArea.bottom,
				rightBorder: res.safeArea.right,
				paddingBottom: res.screenHeight - res.safeArea.bottom
			})
		}
	})
	// #ifdef MP

	const menuButtonData = uni.getMenuButtonBoundingClientRect()

	globalStore.setMenuButton(menuButtonData)
	// #endif
	return {
		app,
		Pinia
	}
}
// #endif